package com.hubiao.pro.service.impl;

import com.hubiao.pro.service.PublisherService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Description
 *
 * @author hubiao
 * @since 2021-01-30 0:19
 */
@Service
public class PublisherServiceImpl implements PublisherService {

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    /**
     * 发送消息
     *
     * @param name
     * @return
     */
    @Override
    public String sendMessage(String name) {
        try {
            stringRedisTemplate.convertAndSend( "TOPIC_USERNAME", name );
            return "消息发送成功了";

        } catch (Exception e) {
            e.printStackTrace();
            return "消息发送失败了";
        }
    }


}
